﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;

namespace Plactice1
{
    class Program
    {
        static void Main(string[] args)
        {
            //定义数据库连接字符串
            string connString = "server=.;database=D3cb;Integrated Security=true";
            SqlConnection conn = new SqlConnection(connString);
            conn.Open();
            if (conn.State == ConnectionState.Open)
            {
                Console.WriteLine("登录成功！！");
                Console.WriteLine();
                Console.WriteLine("============================");
                Console.WriteLine("|  1.添加新管理员    |");
                Console.WriteLine("|  2.修改管理员密码  |");
                Console.WriteLine("|  3.删除管理员      |");
                Console.WriteLine("============================");
                Console.WriteLine();
                Console.WriteLine("请输入你选择的功能序号");
                string select = Console.ReadLine();

                string sql = "";
                string Loginld = "";
                string LoginPwd = "";

                switch (select)
                {
                    case "1":
                        Console.WriteLine("请输入管理员登录账号：");
                        Loginld = Console.ReadLine();
                        Console.WriteLine("请输入管理员登录密码：");
                        LoginPwd = Console.ReadLine();
                        Console.WriteLine("请输入管理员姓名：");
                        string name = Console.ReadLine();

                        sql = string.Format("insert into Admins values('{0}','{1}','{2}')",
                            Loginld, LoginPwd, name);
                        Console.WriteLine("添加成功！");
                        
                        break;

                    case "2":
                        Console.WriteLine("请输入管理员登录账号：");
                        Loginld = Console.ReadLine();
                        Console.WriteLine("请输入管理员登录旧密码：");
                        LoginPwd = Console.ReadLine();
                        Console.WriteLine("请输入管理员登录新密码");
                        string newPwd = Console.ReadLine();
                        sql = string.Format("update Admins set LoginId='{0}' where LoginID='{1}' and" +
                            "LoginPwd='{2}' ", newPwd, Loginld, LoginPwd);
                        Console.WriteLine("修改成功");
                        break;
                    case "3":
                        break;
                }
                conn.Close();
            }

        }
    }
}
